﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>工装批次到料确认</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div class="panelSection">
        <div class="easyui-panel " title="查询区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px">
                <div style="float: left;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        开卡时间：</div>
                    <input id="txtStartContainerTime" class="easyui-datebox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left;margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        批次号：</div>
                    <input id="txtContainerName" class="easyui-textbox" style="width: 150px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        件号：</div>
                    <input id="txtProductName" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        工区：</div>
                    <input id="txtWorkCenter" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        是否到料：</div>
                    <select style='width: 100px; height: 20px' id='selStatus' data-options="value:1,editable:false,panelHeight:'auto'"
                        class='easyui-combobox'>
                        <option value="">全部</option>
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        订单类型：</div>
                    <select style='width: 100px; height: 20px' id='selOrderType' data-options="editable:false,panelHeight:'auto'"
                        class='easyui-combobox'>
                        <option value="">全部</option>
                        <option value="品种">品种</option>
                        <option value="临时">临时</option>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        计划类型：</div>
                    <select style='width: 100px; height: 20px' id='selPlanType' data-options="editable:false,panelHeight:'auto'"
                        class='easyui-combobox'>
                        <option value="">全部</option>
                        <option value="初制">初制</option>
                        <option value="复制">复制</option>
                        <option value="修理">修理</option>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        是否入库：</div>
                    <select style='width: 100px; height: 20px' id='selInstore' data-options="value:0,editable:false,panelHeight:'auto'"
                        class='easyui-combobox'>
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        风险等级：</div>
                    <input id="txtRiskLevel" class="easyui-textbox" style="width: 80px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        重要程度：</div>
                    <input id="txtPriority" class="easyui-textbox" style="width: 80px; height: 20px" />
                </div>
                 <div style="float: left; margin-left: 20px">
                    <button id="btnSearch" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                        width: 80px">
                        查询</button>
                    <button id="btnReset" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                        margin-left: 5px; width: 60px">
                        重置</button>
                </div>
                <div style="clear: both">
                </div>
            </div>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="结果区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px;">
                <table id="gdContainerInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                    data-options="rownumbers:true">
                </table>
                <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]  
                ">
                </div>
            </div>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="按钮区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px">
                <button id="btnConfirm" class="easyui-linkbutton" type="button" style="width: 80px;
                    height: 26px;">
                    已到料</button>
                <button id="bntCancel" class="easyui-linkbutton" type="button" style="width: 80px;
                    height: 26px;">
                    未到料</button>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2023-05-23
    描述：工装批次到料确认js
    */
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/GongZhuangContainer/GZContainerMfgInfoMaint.ashx",
        commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页\
            page.bindWorkCenter();
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdContainerInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pageTotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'PRODUCTNAME', title: '图号', width: 150 },
                 { field: 'CONTAINERNAME', title: '批次号', width: 180 },
                 { field: 'QTY', title: '数量', width: 60 },
                 { field: 'ORIGINALSTARTDATE', title: '开卡时间', width: 100, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 }
                 },
                 { field: 'STARTDATE', title: '开始时间', width: 100, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 } 
                 },
                 { field: 'ENDDATE', title: '结束时间', width: 100, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 } 
                 },
                 { field: 'ORDERTYPE', title: '订单类型', width: 80 },
                 { field: 'PLANTYPE', title: '计划类型', width: 80 },
                 { field: 'ISALLSET', title: '是否齐套', width: 60 },
                 { field: 'PRIORITY', title: '重要程度', width: 60 },
                 { field: 'RISKLEVEL', title: '风险等级', width: 60 },
                 { field: 'CREATENAME', title: '创建人', width: 60 },
                 { field: 'CREATEDATE', title: '创建日期', width: 80, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 } 
                 },
                 { field: 'CHANGENAME', title: '修改人', width: 60 },
                 { field: 'LASTCHANGEDATE', title: '修改日期', width: 80, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 } 
                 }
                ]]
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.clearPage(false, true, true);
                page.pageNumber = 1;
                page.search();
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.search();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.search();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.clearPage(true, true, true);
                page.pageNumber = 1; page.pagetotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
            //状态下拉事件
            $('#selStatus').combobox({
                onSelect: function (record) {
                    clearEasyuiDataGrid("gdContainerInfo"); //清空列表
                }
            });
            //确认
            $('#btnConfirm').on("click", function () {
                page.confirm();
            });
            //取消
            $('#bntCancel').on("click", function () {
                page.cancel();
            });
        },
        //初始化工区下拉数据
        bindWorkCenter: function () {
            page.post(page.ajaxUrl, { action: "GetWorkcenterOfDefault" }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                //绑定查询工区下拉框
                $("#txtWorkCenter").combobox({
                    valueField: 'WORKCENTERID',
                    textField: 'WORKCENTERNAME',
                    panelHeight: 200,
                    data: res.DBTable //下拉数据
                });
                if (res.ReturnData !== null) {
                    $("#txtWorkCenter").combobox('setValue', res.ReturnData);
                }
                page.search();
            });
        },
        //查询
        search: function () {
            var param = {
                isallset: $("#selStatus").combobox("getValue"),
                productName: $("#txtProductName").textbox("getValue"),
                containerName: $("#txtContainerName").textbox("getValue"),
                workCenter: $("#txtWorkCenter").combobox("getValue"),
                startContainerTime: $("#txtStartContainerTime").datebox("getValue"),
                orderType: $("#selOrderType").combobox("getValue"),
                planType: $("#selPlanType").combobox("getValue"),
                riskLevel: $("#txtRiskLevel").textbox("getValue"),
                priority: $("#txtPriority").textbox("getValue"),
                instore: $("#selInstore").combobox("getValue")
            };
            var formData = {
                action: "GetContainerMaterialInfo",
                pageSize: page.pageSize,
                pageIndex: page.pageNumber,
                param:JSON.stringify(param)
            };
            page.post(page.ajaxUrl, formData, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.pageTotal = res.RowCount;
                $("#gdContainerInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //确认
        confirm: function () {
            var containerObj = $("#gdContainerInfo").datagrid("getChecked");
            if (containerObj.length == 0) {
                displayMessage("请选择数据", false);
                return;
            }
            var param = containerObj.map(function (item) {
                return {
                    containerid: item.CONTAINERID,
                    containername: item.CONTAINERNAME
                }
            });
            var formdata = {
                action: "ConfirmGZPrepareManagement",
                param: JSON.stringify(param)
            };
            page.post(page.ajaxUrl, formdata, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.search();
            });
        },
        //取消
        cancel: function () {
            var containerObj = $("#gdContainerInfo").datagrid("getChecked");
            if (containerObj.length == 0) {
                displayMessage("请选择数据", false);
                return;
            }
            var param = containerObj.map(function (item) {
                return {
                    containerid: item.CONTAINERID,
                    containername: item.CONTAINERNAME
                }
            });
            var formdata = {
                action: "CancelGZPrepareManagement",
                param: JSON.stringify(param)
            };
            page.post(page.ajaxUrl, formdata, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.search();
            });
        },
        //清除页面（查询区域，列表区域，填写区域，是否清空消息）
        clearPage: function (query, list, msg) {
            if (query) {
                $("#selStatus").combobox("setValue", "0"); //状态
                $("#txtProductName").textbox("setValue", ""); //件号
                $("#txtContainerName").textbox("setValue", ""); //流水卡
            }
            if (list) {
                clearEasyuiDataGrid("gdContainerInfo"); //清空列表
            }
            if (msg) {
                clearMessage();
            }
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    $("body").find(".easyui-linkbutton").each(function () {
                        $(this).linkbutton('enable');
                    });
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
